package com.atguigu.lease.common.exceptionhandler;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler(value = {BusException.class})
    public Result handleBusException(BusException e) {
        return Result.fail(null,e.getCode(), e.getMessage());
    }

    @ExceptionHandler
    public Result handleException(Exception e) {
        System.out.println(e.getMessage() + e.getCause() + "~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        return Result.fail();
    }
}
